// TimePlayerFrame.cpp : implementation of the CTimePlayerFrame class
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resourcesp.h"

#include "aboutdlg.h"
#include "TimePlayerView.h"
#include "TimePlayerFrame.h"

BOOL CTimePlayerFrame::PreTranslateMessage(MSG* pMsg)
{
	if(CFrameWindowImpl<CTimePlayerFrame>::PreTranslateMessage(pMsg))
		return TRUE; 

	return m_view.IsWindow() ? m_view.PreTranslateMessage(pMsg) : FALSE;
}

bool CTimePlayerFrame::AppHibernate( bool bHibernate)
{
	// Insert your code here or delete member if not relevant
	return bHibernate;
}

bool CTimePlayerFrame::AppNewInstance( LPCTSTR lpstrCmdLine)
{
	// Insert your code here or delete member if not relevant
	return false;
}

void CTimePlayerFrame::AppSave()
{
	CAppInfo info;
	info.Save( m_bFullScreen, L"Full");
	// Insert your code here
}

void CTimePlayerFrame::AppBackKey() 
{
	::SHNavigateBack();
}

BOOL CTimePlayerFrame::OnIdle()
{
	UIUpdateToolBar();
	return FALSE;
}

LRESULT CTimePlayerFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	CAppInfo info;

	// Full screen mode delayed restoration 
	bool bFull = false;
	info.Restore(bFull, L"Full");
	if (bFull)
		PostMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);

	CreateSimpleCEMenuBar();
	AtlActivateBackKey(m_hWndCECommandBar);
	UIAddToolBar(m_hWndCECommandBar);

	m_hWndClient = m_view.Create(m_hWnd);

	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	return 0;
}

LRESULT CTimePlayerFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	PostMessage(WM_CLOSE);
	return 0;
}

LRESULT CTimePlayerFrame::OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: add code to initialize document

	return 0;
}

LRESULT CTimePlayerFrame::OnAction(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: add code

	return 0;
}

LRESULT CTimePlayerFrame::OnFullScreen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	SetFullScreen( !m_bFullScreen );
	UISetCheck( ID_VIEW_FULLSCREEN, m_bFullScreen);
	return TRUE;
}

LRESULT CTimePlayerFrame::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	CAboutDlg dlg;
	FSDoModal(dlg);
	return 0;
}

